<template>
  <div class="nav">
    <el-row class="tac">
      <el-col :span="24">
        <h5>自定义颜色</h5>
        <el-menu
          :default-active="$route.path"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          unique-opened
          router
        >
          <el-submenu :index="item.id" v-for="item in menu" :key="item.id">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>{{ item.title }}</span>
            </template>
            <el-menu-item-group v-for="item2 in item.node" :key="item2.id">
              <el-menu-item :index="'/home'+item2.path">{{ item2.title}}</el-menu-item>
            </el-menu-item-group>
            <!-- <el-submenu index="1-4">
              <template slot="title">选项4</template>
              <el-menu-item index="1-4-1">选项1</el-menu-item>
            </el-submenu> -->
          </el-submenu>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "myNav",
  props: {
    menu: {
      type: Array,
    },
  },
  data() {
    return {};
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
};
</script>

<style scoped lang="scss">
.nav{
    width: 200px;
}
</style>
